﻿/**关于分厅的前端操作  author:WANGYY date:20180912**/
/**begin**/
//父级下拉框数据源信息
//商品代
var parentSource = new Object();
parentSource.FieldEnumDataIns = 'CPOrganIns';
parentSource.FieldEnumDataSource = 'select [DepId] value, [DepName] [text]  FROM   [dbo].[CP_Dep] where  DepType = 6   and DepState=1 order by DepId';

//父母代
var parentsSource = new Object();
parentsSource.FieldEnumDataIns = 'CPOrganIns';
parentsSource.FieldEnumDataSource = 'select [DepId] value, [DepName] [text]  FROM   [dbo].[CP_Dep] where    ParentId = 100000029  and DepType = 6  and DepState=1  order by DepId';
//子集下拉框数据源
var childrenSource = new Object();
childrenSource.FieldEnumDataIns = 'CPOrganIns';
childrenSource.FieldEnumDataSource = 'select   [DepId] as value, [DepName] as text FROM[dbo].[CP_Dep] where ParentId={0} and DepType=7   and DepState=1 order by DepId';

var parentSelect = $(".parent"), parentsSelect = $(".parents"), childrenSelect = $(".children"), childrensSelect = $(".childrens");
//绑定基地信息
var url = "/api/HatchRoom/GetSourceInfo";


$(document).ready(function () {  
   
    //商品代
    $.ajax({
        type: "POST",
        url: url,
        data: JSON.stringify(parentSource),
        contentType: 'application/json',
        success: function (data) {
            if (data.length != 0) {
                //返回的数据不为空 
                parentSelect.html("");
                //json字符串转化为json对象
                data = eval('(' + data + ')');
                var parentSelected = "";
                data = eval('(' + data.Column + ')');
                for (var i = 0; i < data.length; i++) {
                    var columnObj = data[i];
                    if (i == 0) parentSelected = columnObj.valueEx;
                    var html = "<option value ='" + columnObj.valueEx + "'> " + columnObj.textEx + "</option>";
                    parentSelect.append(html);
                }
                var chSource = new Object();
                chSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
                chSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentSelected);
                $.ajax({
                    type: "POST",
                    url: url,
                    data: JSON.stringify(chSource),
                    contentType: 'application/json',
                    success: function (val) {
                        if (val.length != 0) {
                            childrenSelect.html("");
                            val = eval('(' + val + ')');
                            val = eval('(' + val.Column + ')');
                            for (var i = 0; i < val.length; i++) {
                                var childcolumnObj = val[i];
                                var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                                childrenSelect.append(html);
                            }
                        }
                    }
                });
            } else {
                //返回的数据为空 
                parentSelect.hide();
                childrenSelect.hide();
            }
        },
        error: function (error) {
            console.log(error.statusText);
        }
    });
    //父母代
    $.ajax({
        type: "POST",
        url: url,
        data: JSON.stringify(parentsSource),
        contentType: 'application/json',
        success: function (data) {
            if (data.length != 0) {
                //返回的数据不为空 
                parentsSelect.html("");
                //json字符串转化为json对象
                data = eval('(' + data + ')');
                var parentsSelected = "";
                data = eval('(' + data.Column + ')');
                for (var i = 0; i < data.length; i++) {
                    var columnObj = data[i];
                    if (i == 0) parentsSelected = columnObj.valueEx;
                    var html = "<option value ='" + columnObj.valueEx + "'> " + columnObj.textEx + "</option>";
                    parentsSelect.append(html);
                }
                var chSource = new Object();
                chSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
                chSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentsSelected);
                $.ajax({
                    type: "POST",
                    url: url,
                    data: JSON.stringify(chSource),
                    contentType: 'application/json',
                    success: function (val) {
                        if (val.length != 0) {
                            childrensSelect.html("");
                            val = eval('(' + val + ')');
                            val = eval('(' + val.Column + ')');
                            for (var i = 0; i < val.length; i++) {
                                var childcolumnObj = val[i];
                                var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                                childrensSelect.append(html);
                            }
                        }
                    }
                });
            } else {
                //返回的数据为空 
                parentsSelect.hide();
                childrensSelect.hide();
            }
        },
        error: function (error) {
            console.log(error.statusText);
        }
    });

    //商品代-父级下拉框change事件
    $(".parent").on('change', function () {
        var parentSelected = $(this).val();
        //移除之前的选中       
        $.each($(this).children("option"), function (nIndex, obj) {           
            if (obj.value == parentSelected) return true;
            $(this).removeAttr("selected");
        });
        $(this).children("option[value='" + parentSelected + "']").attr("selected", true); 
        // alert($(this).val());
        var childObj = $(this).next();
        var chilSource = new Object();
        chilSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
        chilSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentSelected);
        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(chilSource),
            contentType: 'application/json',
            success: function (val) {
               // debugger
                if (val.length != 0) {
                    childObj.html("");
                    val = eval('(' + val + ')');
                    val = eval('(' + val.Column + ')');
                    for (var i = 0; i < val.length; i++) {
                        var childcolumnObj = val[i];
                        var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                        childObj.append(html);
                    }
                }
            }
        });
    });
    //子级下拉框change事件
    $(".children").on('change', function () {
        var childrenSelected = $(this).val();
        $(this).children("option[value='" + childrenSelected + "']").attr("selected", "selected"); 
    });

     //商品代-父级下拉框change事件
    $(".parents").on('change', function () {
        var parentsSelected = $(this).val();
        //移除之前的选中       
        $.each($(this).children("option"), function (nIndex, obj) {
            if (obj.value == parentSelected) return true;
            $(this).removeAttr("selected");
        });
        $(this).children("option[value='" + parentsSelected + "']").attr("selected", true);
        // alert($(this).val());
        var childObj = $(this).next();
        var chilSource = new Object();
        chilSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
        chilSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentSelected);
        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(chilSource),
            contentType: 'application/json',
            success: function (val) {
                // debugger
                if (val.length != 0) {
                    childObj.html("");
                    val = eval('(' + val + ')');
                    val = eval('(' + val.Column + ')');
                    for (var i = 0; i < val.length; i++) {
                        var childcolumnObj = val[i];
                        var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                        childObj.append(html);
                    }
                }
            }
        });
    });
    //子级下拉框change事件
    $(".childrens").on('change', function () {
        var childrensSelected = $(this).val();
        $(this).children("option[value='" + childrensSelected + "']").attr("selected", "selected");
    });
    

});        



String.prototype.format = function () {

    if (arguments.length == 0) return this;
    for (var s = this, i = 0; i < arguments.length; i++)
        s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
    return s;

};
//获取选中radio的值，获取行数据
function CPGridGetRadioSelTRData() {
   // debugger
    var Items = new Object();
    $.each($(".CPGridRadioCss"), function (nIndex, nObj) {
        if ($(nObj).is(':checked')) {
            if (Items.length > 0) return false;
            Items.DataPK = $(nObj).val();
            Items.FieldNamCol = new Array();
            Items.FieldValueCol = new Array();
            Items.FieldState = new Array();
            Items.RowObj = new Object();
            Items.TableObj = new Object();
            $.each(CPGridGlobal_GridObj.ColumnCol, function (cIndex, cObj) {
                if (cObj.ColumnType == 4) {
                    Items.FieldNamCol.push(cObj.FieldName);
                    Items.FieldValueCol.push($("#CPGridEditControl_" + cObj.FieldName + "_" + Items.DataPK).val());
                    Items.FieldState.push(cObj.IsShow);
                }
            });
            var trobj = $(nObj).parents('tr');//需要复制的行内容
            Items.RowObj = trobj;
            var tableObj = $(nObj).parents('table');//需要新增数据的table对象           
            Items.tableObj = tableObj;
            Items.RowNum = nIndex;
        } else {
            if (Items.RowObj != undefined && Items.RowObj.length > 0) return false;
            else return true;
        }
    });
    return Items;
}

//获取选中check的值，获取行数据
function CPGridGetCheckSelTRData() {
    // debugger
    var Items = new Array();
    $.each($(".CPGridChkCss"), function (nIndex, nObj) {
        if ($(nObj).is(':checked')) {
            //if (Items.length > 0) return false;
            var tmp = new Object();
            tmp.DataPK = $(nObj).val();
            tmp.FieldNamCol = new Array();
            tmp.FieldValueCol = new Array();
            tmp.FieldState = new Array();
            tmp.RowObj = new Object();
            tmp.TableObj = new Object();
            $.each(CPGridGlobal_GridObj.ColumnCol, function (cIndex, cObj) {
                if (cObj.ColumnType == 4) {
                    tmp.FieldNamCol.push(cObj.FieldName);
                    tmp.FieldValueCol.push($("#CPGridEditControl_" + cObj.FieldName + "_" + Items.DataPK).val());
                    tmp.FieldState.push(cObj.IsShow);
                }
            });
            var trobj = $(nObj).parents('tr');//需要复制的行内容
            tmp.RowObj = trobj;
            var tableObj = $(nObj).parents('table');//需要新增数据的table对象           
            tmp.tableObj = tableObj;
            tmp.RowNum = nIndex;
            Items.push(tmp);
        } else {
            if (Items.RowObj != undefined && Items.RowObj.length > 0) return false;
            else return true;
        }

    });
    return Items;
}
//editor:WANGYY  date:20180910  desc:选中行新增行，初始化
function CPGridInsertPitchOnData() {
    //debugger
    var inputObj = new Object();
    var that = this;
    inputObj.Items = CPGridGetCheckSelTRData();
    if (inputObj.Items.length == 0) {
        alert("请选择要修改的数据！");
        return false;   
    }
    inputObj.GridCode = CPGridGlobal_GridObj.GridCode;
    inputObj.CurUserId = CPCurUserId;
    inputObj.CurUserIden = CPCurUserIden;

    
    
    ////添加行
    //var tableObj = inputObj.Items.tableObj;
    //var nIndex = inputObj.Items.RowNum;
    //var newTR = inputObj.Items.RowObj;
    //if (tableObj === undefined) return;
    //var $tr = tableObj.find('tr').eq(nIndex);

   
    //$tr.after(newTR[0].outerHTML);
    //tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('label').text('删除');
    //tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('label').css("color", "blue");
    //tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('input').css("display", "none");
    //tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('input').removeClass("CPGridRadioCss");
    ////tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('input').remove();
    //tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).attr("onclick", "deleteNewTR(this)");
  

    //添加行
    if (inputObj.Items.length > 0) {
        $.each(inputObj.Items, function (index, obj) {
            var tableObj = obj.tableObj;
            var nIndex = obj.RowNum;
            var newTR = obj.RowObj;
            if (tableObj === undefined) return;
            if (index > 0) nIndex += index;
            var $tr = tableObj.find('tr').eq(nIndex);


            $tr.after(newTR[0].outerHTML);
            tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).append('<label style="color:blue" class="addtr">删除</label');
            tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('input').css("display", "none");
            tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).find('input').removeClass("CPGridRadioCss");
            tableObj.find('tr').eq(nIndex + 1).find('td').eq(0).attr("onclick", "deleteNewTR(this)");
        });
    }

    //父级下拉框change事件
    $(".parent").on('change', function () {

        
        var parentSelected = $(this).val();

        $(this).children("option[value='" + parentSelected + "']").attr("selected", "selected");
        var childObj = $(this).next();
        var chilSource = new Object();
        chilSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
        chilSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentSelected);
        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(chilSource),
            contentType: 'application/json',
            success: function (val) {
                if (val.length != 0) {
                    childObj.html("");
                    val = eval('(' + val + ')');
                    val = eval('(' + val.Column + ')');
                    for (var i = 0; i < val.length; i++) {
                        var childcolumnObj = val[i];
                        var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                        childObj.append(html);
                    }
                }
            }
        });
    });
    //子级下拉框change事件
    $(".children").on('change', function () {
        var childrenSelected = $(this).val();
        $(this).children("option[value='" + childrenSelected + "']").attr("selected", "selected");
    });

   
}



//删除新增的行
function deleteNewTR(temp) {
    if (confirm('是否要删除本行数据？')) {
        $(temp).parents('tr').remove();
    }
}


function CPGridGetALLRadioData() {
    var Items = new Object();
    $.each($(".CPGridRadioCss"), function (nIndex, nObj) {
        if (Items.length > 0) return false;
        var tableObj = $(nObj).parents('tbody');//需要新增数据的table对象           
        Items.tableObj = tableObj;
    });
    return Items;
}

//editor:WANGYY  date:20180917  desc:列表整体数据保存
function CPGridSaveListData() {
    debugger    

    var inputObj = new Object();
    inputObj.Items = CPGridGetListDataWhenSave();
    if (inputObj.Items.length <= 0) {
        alert("请选择要分厅的数据！");
        return false;
    }
    //设置按钮不可点击
    $("#CPGrid_FuncBtn_9216").attr("disabled", true);
    inputObj.GridCode = CPGridGlobal_GridObj.GridCode;
    inputObj.CurUserId = CPCurUserId;
    inputObj.CurUserIden = CPCurUserIden;
    if (!verify(inputObj.Items)) { alert("进雏数量+路耗数量+调整数量与孵化厅数量+路耗数量不符，请重新设置"); return false; }
    var saveUrl = CPWebRootPath + "/api/HatchRoom/SaveGridData";

     $.ajax({
        type: "POST",
        url: saveUrl,
        data: JSON.stringify(inputObj),
        contentType: 'application/json',
        success: function (data) {
            if (data.Result == false) {
                alert("保存失败，详细信息：" + data.ErrorMsg);
                $("#CPGrid_FuncBtn_9216").attr("disabled", false);
                return false;
            }
            else {
                alert("保存成功！");
                CPGridRefresh();
            }
        }
    });
}


//获取所有数据
function CPGridGetListDataWhenSave() {
    var Items = new Array();
    //$.each($(".k-grid-content table tbody tr"), function (nIndex, nObj) {
    $.each($(".CPGridChkCss"), function (nIndex, nObj) {
        //debugger
        if ($(nObj).is(':checked')) {
            var tmp = new Object();
            var tdobj = $(nObj).parents('tr')[0].childNodes;
            var RadioObj = $(this).find("input[id^='CPGirdDiv_Radio_']");
            tmp.Id = $(nObj).val();
            tmp.OrderId = $("#CPGridControl_OrderId_" + tmp.Id)[0].innerHTML;
            //tmp.OrderChildId = tdobj[3].innerText;
            tmp.VarietyName = $("#CPGridControl_VarietyName_" + tmp.Id)[0].innerText;
            tmp.GoodsName = $("#CPGridControl_GoodsName_" + tmp.Id)[0].innerText;
            var selectHtml = tdobj[9];
            var selectObj = $(selectHtml);
            var parentObj = $(selectHtml).find('select:eq(0)');
            var childrenObj = $(selectHtml).find('select:eq(1)');
            tmp.BaseId = parentObj.val();
            tmp.BaseName = parentObj.find("option:selected").text();
            tmp.HallId = childrenObj.val();
            tmp.HallName = childrenObj.find("option:selected").text();
            var BuyChickObj = $("input[id='CPGridEditControl_BuyChickCount_" + tmp.Id + "']"); //$(this).find("input[id^='CPGridEditControl_BuyChickCount_']");
            if (BuyChickObj.val() === "")
                tmp.BuyChickCount = 0;
            else
                tmp.BuyChickCount = parseInt(BuyChickObj.val());
            var HallLossObj = $("input[id='CPGridEditControl_LossCount_" + tmp.Id + "']");//$(this).find("input[id^='CPGridEditControl_LossCount']");
            if (HallLossObj.val() === "")
                tmp.HallLossCount = 0;
            else
                tmp.HallLossCount = parseInt(HallLossObj.val());
            tmp.TotalCount = tdobj[7].innerText;
            tmp.OrderRoadLoss = tdobj[8].innerText;
            tmp.AdjustNumber = tdobj[13].innerText;
            tmp.OrderChildId = $("#CPGridEditControl_OrderChildId_" + tmp.Id).val().replace(/(^[\s\n\t]+|[\s\n\t]+$)/g, "");
            Items.push(tmp);
        }
    });
    return Items;
}


//保存校验【验证孵化厅数量、孵化厅路耗】
function verify(Items) {
    debugger
    $("input[id^='CPGridEditControl_BuyChickCount_']").removeAttr("style");
    $("input[id^='CPGridEditControl_LossCount_']").removeAttr("style");
    if (Items === undefined) return false;
    var idValue = "", id = 0, BuyChickCount = 0, HallLossCount = 0, mark = 0;
    var ChickItems = new Array();
    $.each(Items, function (nIndex, nObj) {
        //debugger;
        var tmp = new Object();
        if (idValue == nObj.OrderChildId) {
            HallLossCount += parseInt(nObj.HallLossCount);
            BuyChickCount += parseInt(nObj.BuyChickCount);
        }
        else {
            id = nObj.Id;
            idValue = nObj.OrderChildId;
            HallLossCount = parseInt(nObj.HallLossCount);
            BuyChickCount = parseInt(nObj.BuyChickCount);
        }
        if (HallLossCount + BuyChickCount != parseInt(nObj.TotalCount) + parseInt(nObj.OrderRoadLoss) + parseInt(nObj.AdjustNumber) && BuyChickCount != 0) {
            tmp.OrderChildId = $("#CPGridEditControl_OrderChildId_" + id).val();
            //tmp.BuyChickCount = "CPGridEditControl_BuyChickCount_" + idValue;
            //tmp.HallLossCount = "CPGridEditControl_LossCount_" + idValue;
        } else ChickItems = RemoveArrayItem(ChickItems, $("#CPGridEditControl_OrderChildId_" + id).val());
        if (!$.isEmptyObject(tmp)) ChickItems.push(tmp);
    });
    if (ChickItems.length > 0) {
        $.each(ChickItems, function (cIndex, cObj) {
            $("input[value='" + cObj.OrderChildId + "']").parents('tr').find("input[id^='CPGridEditControl_BuyChickCount_']").css('background-color', '#d81e06');
            $("input[value='" + cObj.OrderChildId + "']").parents('tr').find("input[id^='CPGridEditControl_LossCount_']").css('background-color', '#d81e06');
            //$("input[id^='" + cObj.BuyChickCount + "']").css('background-color', '#d81e06'); 
            //$("input[id^='" + cObj.HallLossCount + "']").css('background-color', '#d81e06'); 
        });
        return false;
    } else return true;
}

//删除数组中的指定项
function RemoveArrayItem(items, value) {
    if (items === undefined) return false;
    var ChItems = new Array();
    ChItems = items;
    for (var i = 0; i < ChItems.length; i++) {
        if (ChItems[i].OrderChildId == value) items = items.splice($.inArray(value, items), i);
    }
    return items;
}


//批量设置“基地+孵化厅”
function setBatch() {

    var inputObj = new Object();
    inputObj.Items = CPGridGetListDataWhenSave();
    if (inputObj.Items.length <= 0) {
        alert("请选择要批量设置的订单数据！");
        return false;
    }
    var parentHtml = '<select id="parselect" onchange="parChange(this)">';
    parentHtml += '<option value = "100000002">京孵1 - 4厅孵化基地</option> ';
    parentHtml += '<option value = "100000005">北镇孵化基地</option>';
    parentHtml += '<option value = "100000007">洛阳孵化基地</option>';
    parentHtml += '<option value = "100000009">金乡孵化基地</option>';
    parentHtml += '<option value = "100000011">湖北孵化基地</option>';
    parentHtml += '<option value = "100000023">江苏孵化基地</option>';
    parentHtml += '<option value = "100000026">云南孵化基地</option>';
    parentHtml += '<option value = "100000030">育种公司孵化基地</option>';
    parentHtml += '</select>';
    var childrenHtml = '<select id="childselect">';
    childrenHtml += '<option value = "100000012">京孵1厅</option>';
    childrenHtml += '<option value = "100000013">京孵2厅</option>';
    childrenHtml += '<option value = "100000014">京孵3厅</option>';
    childrenHtml += '<option value = "100000015">京孵4厅</option>';
    childrenHtml += '</select>';
    var index = layer.open({
        type: 1,//Layer提供了5种层类型。可传入的值有：0（信息框，默认）1（页面层）2（iframe层）3（加 载层）4（tips层）,
        title: '分厅信息',   //标题
        skin: 'layer-ext-moon',//皮肤
        shade: 0.4,   //遮罩透明度
        area: '300px;', //宽高
        id: 'LAY_layuipro', //设定一个id，防止重复弹出
        resize: false,
        btn: ['确定', '取消'],
        moveType: 1, //拖拽模式，0或者1
        content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' + parentHtml + childrenHtml + '</div>',
        btn1: function () {
            debugger;
            var parentval = $("#parselect").val();
            var childrenval = $("#childselect").val();
            $.each($(".CPGridChkCss"), function (nIndex, nObj) {
                if ($(nObj).is(':checked')) {
                    var tdobj = $(nObj).parents('tr')[0].childNodes;
                    var selectHtml = tdobj[10];
                    var parentObj = $(selectHtml).find('select:eq(0)');
                    var childrenObj = $(selectHtml).find('select:eq(1)');
                    var beginValue = parentObj.val();
                    parentObj.val(parentval);
                    if (beginValue != parentval) //$(parentObj).trigger("change");//调用父级select的change事件
                    {
                        var $this = $(parentObj);
                        var parentSelected = $this.val();

                        $this.children("option[value='" + parentSelected + "']").attr("selected", "selected");
                        var childObj = $this.next();
                        var chilSource = new Object();
                        chilSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
                        chilSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentSelected);
                        $.ajax({
                            type: "POST",
                            url: url,
                            data: JSON.stringify(chilSource),
                            contentType: 'application/json',
                            success: function (val) {
                                if (val.length != 0) {
                                    childObj.html("");
                                    val = eval('(' + val + ')');
                                    val = eval('(' + val.Column + ')');
                                    for (var i = 0; i < val.length; i++) {
                                        var childcolumnObj = val[i];
                                        var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                                        childObj.append(html);
                                    }
                                }
                                childrenObj.val(childrenval);
                            }
                        });
                    }
                    childrenObj.val(childrenval);
                }
            });
            layer.close(index);
        },//第一个按钮的点击事件
        btn2: function () {
            layer.close(index);
        }//第二个按钮的点击事件


    });
}
//selectchange事件
function parChange(obj) {
    debugger
    var parentsSelected = $(obj).val();
    //移除之前的选中       
    //$.each($(obj).children("option"), function (nIndex, obj) {
    //    if (obj.value == parentSelected) return true;
    //    $(obj).removeAttr("selected");
    //});
    //$(obj).children("option[value='" + parentsSelected + "']").attr("selected", true);
    // alert($(this).val());
    var childObj = $("#childselect");
    var chilSource = new Object();
    chilSource.FieldEnumDataIns = childrenSource.FieldEnumDataIns;
    chilSource.FieldEnumDataSource = childrenSource.FieldEnumDataSource.format(parentsSelected);
    $.ajax({
        type: "POST",
        url: url,
        data: JSON.stringify(chilSource),
        contentType: 'application/json',
        success: function (val) {
            // debugger
            if (val.length != 0) {
                childObj.html("");
                val = eval('(' + val + ')');
                val = eval('(' + val.Column + ')');
                for (var i = 0; i < val.length; i++) {
                    var childcolumnObj = val[i];
                    var html = "<option value='" + childcolumnObj.valueEx + "'>" + childcolumnObj.textEx + "</option>";
                    childObj.append(html);
                }
            }
        }
    });
}
/**end**/
    
    
    

         
       








